import request from '@/utils/request'

const basePath = '/jpower-system'

/**
 * @description: 查询所有字典类型
 * @param {*}
 * @return {*}
 */
export function dictTypeTree() {
  return request({
    url: basePath + '/core/dict/dictTypeTree',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

/**
 * @description: 新建字典类型
 * @param {type}
 * @return {type}
 */
export function createDictType(params) {
  return request({
    url: basePath + '/core/dict/add',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 删除字典类型
 * @param {*} ids
 * @return {*}
 */
export function removeDictType(ids) {
  return request({
    url: basePath + '/core/dict/deleteDictType',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { ids }
  })
}

/**
 * @description: 更新字典类型
 * @param {*} ids
 * @return {*}
 */
export function updateDictType(params) {
  return request({
    url: basePath + '/core/dict/update',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 查询字典类型详情
 * @param {type}
 * @return {type}
 */
export function getDictType(id) {
  return request({
    url: basePath + '/core/dict/getDictType',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { id }
  })
}

/**
 * @description: 查询字典详情
 * @param {type}
 * @return {type}
 */
export function getDict(id) {
  return request({
    url: basePath + '/core/dict/getDict',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { id }
  })
}

/**
 * @description: 通过字典类型查询字典列表
 * @param {type}
 * @return {type}
 */
export function getDictListByType(params) {
  return request({
    url: basePath + '/core/dict/getDictListByType',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 通过字典类型分页查询字典列表
 * @param {*} params
 * @return {*}
 */
export function getListByType(params) {
  return request({
    url: basePath + '/core/dict/listByType',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 保存或新增字典
 * @param {*} params
 * @return {*}
 */
export function createDic(params) {
  return request({
    url: basePath + '/core/dict/saveDict',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

export function removeDic(ids) {
  return request({
    url: basePath + '/core/dict/deleteDict',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { ids }
  })
}

/**
 * @description: 查询下级字典
 * @param {*} params
 * @return {*}
 */
export function findChildrenDic(params) {
  return request({
    url: basePath + '/core/dict/listDictChildList',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

